home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10528 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Determining the length of an int in string form
  5. Date: Mon, 18 Mar 96 15:32:23 GMT
  6. Organization: none
  7. Message-ID: <827163143snz@genesis.demon.co.uk>
  8. References: <3146D058.DD7@cbm.com> <4i7uth$qph@inet-nntp-gw-1.us.oracle.com> <DoE38u.GIH@iquest.net>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <DoE38u.GIH@iquest.net>
  15.            dlmiller@iquest.net "Doug & Rose Miller" writes:
  16.  
  17. >wkaufman@wkaufman.us.oracle.com (William Kaufman) wrote:
  18. >+In article <3146D058.DD7@cbm.com> Dave Payne <paynedc@cbm.com> writes:
  19. >+] Consider this:
  20. >+]
  21. >+] I have a variable of type int, and I would like to use the sprintf()
  22. >+] function to write this variable to a string.  However, I want to
  23. >+] dynamically allocate the space for the string, and only malloc enough
  24. >+] space to hold the int.
  25. >
  26. >WHY ???
  27. >
  28. >Even a 32-bit int is only 9 characters at most, and that's *with* the sign. 
  29.  
  30. -2147483647 is a valid 32 bit int and is 11 characters (excluding the null
  31. character string terminator). The problem of course is that ints aren't
  32. limited to 32 bits - the language imposes no upper limit to their size.
  33.  
  34. -- 
  35. -----------------------------------------
  36. Lawrence Kirby | fred@genesis.demon.co.uk
  37. Wilts, England | 70734.126@compuserve.com
  38. -----------------------------------------
  39.